package com.ash.plough;

import java.util.HashMap;
import java.util.Map;

public class Main {

    private static Map<String, String> chineseZodiacMap = new HashMap<String, String>() {

        {
            put("鼠", "木");
            put("牛", "火");
            put("虎", "土");
            put("兔", "金");
            put("龙", "水");
            put("蛇", "火");
            put("马", "木");
            put("羊", "火");
            put("猴", "土");
            put("鸡", "金");
            put("狗", "水");
            put("猪", "水");

        }
    };

    private static Map<String, String> earthlyBranchMap = new HashMap<String, String>() {

        {
            put("子", "木");
            put("丑", "火");
            put("寅", "土");
            put("卯", "金");
            put("辰", "水");
            put("巳", "火");
            put("午", "木");
            put("未", "火");
            put("申", "土");
            put("酉", "金");
            put("戌", "水");
            put("亥", "水");
        }
    };

    private static Map<Integer, String> monthMap = new HashMap<Integer, String>() {

        {
            put(1, "木");
            put(2, "火");
            put(3, "土");
            put(4, "金");
            put(5, "水");
            put(6, "火");
            put(7, "木");
            put(8, "火");
            put(9, "土");
            put(10, "金");
            put(11, "水");
            put(12, "水");
        }
    };

    private static Map<Integer, String> fourSeasonMap = new HashMap<Integer, String>() {

        {
            put(1, "木");
            put(2, "木");
            put(3, "木");
            put(4, "火");
            put(5, "火");
            put(6, "火");
            put(7, "金");
            put(8, "金");
            put(9, "金");
            put(10, "水");
            put(11, "水");
            put(12, "水");
        }
    };

    private static Map<String, Integer> earthNumber = new HashMap<String, Integer>() {

        {
            put("子", 1);
            put("丑", 2);
            put("寅", 3);
            put("卯", 4);
            put("辰", 5);
            put("巳", 6);
            put("午", 7);
            put("未", 8);
            put("申", 9);
            put("酉", 10);
            put("戌", 11);
            put("亥", 12);
        }
    };

    public static void main(String[] args) {
        String year = getZodiac(1988);
        int month = 11;
        int day = 29;
        String hour = getEarthlyBranch(9);

        dou(year, month, day, hour);

    }

    private static void dou(String year, int month, int day, String hour) {
        String one = chineseZodiacMap.get(year);

        System.out.println(one);

        String two = monthMap.get(month);

        System.out.println(two);

        int tempday = (day > 24) ? (day - 24) : (day > 12 ? day - 12 : day);
        String three = monthMap.get(tempday);

        System.out.println(three);


        String four = earthlyBranchMap.get(hour);

        System.out.println(four);


        String five = fourSeasonMap.get(month);


        System.out.println(five);


        String six;
        if (day > 12 && (month == 3 || month == 6 || month == 9 || month == 12)) {
            six = "土";
        } else if (day > 12) {
            int tempday1 = (day > 24) ? (day - 24) : (day > 12 ? day - 12 : day);
            six = fourSeasonMap.get(tempday1);
        } else {
            six = fourSeasonMap.get(day);
        }


        System.out.println(six);


        String seven = fourSeasonMap.get(earthNumber.get(hour));

        System.out.println(seven);
    }


    public static String getZodiac(int year) {
        // 生肖数组，表示12个生肖的顺序
        String[] zodiacs = {"鼠", "牛", "虎", "兔", "龙", "蛇", "马", "羊", "猴", "鸡", "狗", "猪"};

        // 计算对应的生肖索引
        int index = (year - 1900) % 12;

        // 如果索引是负数，需要调整为正数
        if (index < 0) {
            index += 12;
        }

        // 返回对应的生肖
        return zodiacs[index];
    }

    public static String getEarthlyBranch(int hour) {
        // 地支数组，表示12个地支的顺序
        String[] earthlyBranches = {"子", "丑", "寅", "卯", "辰", "巳", "午", "未", "申", "酉", "戌", "亥"};

        // 确定时辰的索引，根据24小时制，将小时分为12个时辰
        int index;
        if (hour >= 23 || hour < 1) {
            index = 0;  // 子时 (23:00-01:00)
        } else if (hour >= 1 && hour < 3) {
            index = 1;  // 丑时 (01:00-03:00)
        } else if (hour >= 3 && hour < 5) {
            index = 2;  // 寅时 (03:00-05:00)
        } else if (hour >= 5 && hour < 7) {
            index = 3;  // 卯时 (05:00-07:00)
        } else if (hour >= 7 && hour < 9) {
            index = 4;  // 辰时 (07:00-09:00)
        } else if (hour >= 9 && hour < 11) {
            index = 5;  // 巳时 (09:00-11:00)
        } else if (hour >= 11 && hour < 13) {
            index = 6;  // 午时 (11:00-13:00)
        } else if (hour >= 13 && hour < 15) {
            index = 7;  // 未时 (13:00-15:00)
        } else if (hour >= 15 && hour < 17) {
            index = 8;  // 申时 (15:00-17:00)
        } else if (hour >= 17 && hour < 19) {
            index = 9;  // 酉时 (17:00-19:00)
        } else if (hour >= 19 && hour < 21) {
            index = 10; // 戌时 (19:00-21:00)
        } else {
            index = 11; // 亥时 (21:00-23:00)
        }

        // 返回对应的地支
        return earthlyBranches[index];
    }
}
